#include "printf.h"
#include <stdio.h>

int fputc(int ch, FILE *file)
{
	USART_SendData(USART1, ch);
	
	while(USART_GetFlagStatus(USART1, USART_FLAG_TXE) == RESET);
	
	return ch;
}

void Send_Char(char ch)
{
	USART_SendData(USART1, ch);
	 
	while(USART_GetFlagStatus(USART1, USART_FLAG_TXE) == RESET);
}

void Send_String(char *str)
{
	while(*str != '\0')
	{
		USART_SendData(USART1, *str);
		 
		while(USART_GetFlagStatus(USART1, USART_FLAG_TXE) == RESET);
		str++;
	}
}

uint8_t USART_ReceiveChar(USART_TypeDef* USARTx)
{
	while (USART_GetFlagStatus(USARTx, USART_FLAG_RXNE) == RESET);
  return (uint8_t)USART_ReceiveData(USARTx);
}
